import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import applybase from '../router/applybase.js'
import adsServer from '../router/adsServer.js'
const _import = require('./config/_import_' + process.env.NODE_ENV)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: 'login'
  },
  {
    path: '/login',
    name: 'login',
    component: Home
  },
  {
    path: '/findPsw/:uname/:sign',
    name: 'findPsw',
    component: () => import('@/views/findPsw.vue')
  },
  {
    path: '/index',
    name: 'index',
    meta: {
      requireAuth: false
    },
    component: () => import('@/views/index.vue')
  },
  {
    path: '/Chat/:id',
    name: 'Chat',
    meta: {
      requireAuth: false
    },
    component: () => import('@/views/Chat.vue')
  }
  
]
const router = new VueRouter({
  //mode: 'history',
  base: process.env.BASE_URL,
  scrollBehavior: () => ({ y: 0 }),
  routes: [
    ...routes,
    // ...applybase,
    // ...adsServer
  ]
})

export default router
